package club.wx3609.images.pool;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Component
public class UserRegisterPool {
    public static Map<String, String> map=new HashMap<String,String>();

    @Async
    @Scheduled(cron="* * * * * *")
    protected void deleteMap(){
        long time=new Date().getTime();
        for(String key:map.keySet()){
            long dateOld=Long.valueOf(map.get(key));
            if(time>=dateOld){
                map.remove(key);
                System.out.printf(key+"解除封印");
            }
        }
    }
}
